package Test;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class Test1 {
    //服务器上存有多个用户对象,考虑用List或者Map（对象包括用户和密码），客户端通过socket登录，如果成功，输出欢迎信息，失败给出提示。
    public static void main(String[] args) {

        try {
            Socket s = new Socket("localhost", 8888);
            InputStream in = s.getInputStream();
            OutputStream out = s.getOutputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            PrintWriter pw = new PrintWriter(out, true);
            Scanner input = new Scanner(System.in);
            System.out.println("请输入用户名：");
            String uesr = input.next();
            System.out.println("请输入密码：");
            String pass = input.next();
            pw.println(uesr);
            pw.println(pass);
            String reply = br.readLine();
            System.out.println(reply);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
